package com.young.operation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.young.operation.mapper.DeptMapper;
import com.young.operation.model.Dept;
import com.young.operation.service.DeptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Slf4j
@RequiredArgsConstructor
@Service
public class DeptServiceImpl implements DeptService {

    private final DeptMapper deptMapper;

    @Override
    public Page<Dept> queryPage(String name, Integer pageNum, Integer pageSize) {
        QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
        if (StringUtils.hasLength(name)) queryWrapper.like("name", name);
        Page<Dept> page = new Page<>(pageNum, pageSize);
        return deptMapper.selectPage(page, queryWrapper);
    }
}
